import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import { createSvg } from './src/icons/index'
// Rollup 的虚拟模块
// import versionUpdatePlugin from './src/utils/versionUpdatePlugin'

const path = require('path')
// 打包时生成一个版本信息
const CurrentTimeVersion = new Date().getTime();

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    vue(),
    vueSetupExtend(),
    createSvg('./src/icons/svg/'), 
    // versionUpdatePlugin({
    //   version: CurrentTimeVersion,
    // }),
  ],
  define: {
		// 定义版本信息
		'process.env.VITE__APP_VERSION__': CurrentTimeVersion,
	},
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
    },
  },
  css: {
    // css预处理器
    preprocessorOptions: {
      scss: {
        additionalData: 
          '@import "./src/styles/variables.scss";@import "./src/styles/mixin.scss";',
      },
    },
  },
  server: {
    proxy: {
      '/base-api': {
        // 代理的目标地址
        //target: 'https://applet.shengweiswcr.com/base-api',
        //target: 'http://www.yz-practice.cn:8080/base-api',
        target: 'http://47.120.78.135:8094',
        //target: 'http://localhost:8094',
        changeOrigin: true,

        // 前缀置空
        rewrite: (path) => path.replace(/^\/base-api/, ''),
      },
    },
    host: '0.0.0.0'
  },

})
